﻿using System;
using System.IO;
using FBGraph.Models;

namespace FBGraph.Controllers
{
    public partial class PhotosController : IFBGraphPrimaryController<Photo>
    {
        /// <summary>Uploads a photo to the specified album.</summary>
        /// <param name="albumId">The id of the album that will be receiving the photo.</param>
        /// <param name="caption">A caption for the photo.</param>
        /// <param name="filename">The filename of the photo being uploaded.</param>
        /// <param name="contentType">The MIME content type of the file being uploaded.</param>
        /// <param name="data">A <see cref="Byte" /> array containing the photo.</param>
        /// <returns>The Graph API identifier of the photo that was uploaded.</returns>
        public Object Upload(Object albumId, String caption, String filename, String contentType, Stream data)
        {
            var args = new FBArgs { { "message", caption } };

            var result = Context.PostFile(albumId, "photos", args, filename ?? "photo.jpg", "photo", contentType ?? "image/jpg", data);

            return result.Id;
        }
    }
}